/**
 * author: zhangwei
 * 角色管理列表
 */
var main = {

    init: function() {
        this.initTable();
        this.tabBind();
    },
    initTable: function() {
        var _this=this;
        setCollegeList()
    },
    tabBind: function() {
        $('body').on('click','.college',function(){
            id = $(this).attr("data-id")
            localStorage.id = id
            parent.$t.goToPage(this, "/college/guide");
        })

    }
}
main.init();



function getCollegeList() {
    data = []
    $.ajax({
        type:"get",
        async:false,
        url:'/college/queryCollege',
        success:function(result) {
            if (result.code == property.successCode) {
                data = result.data
            } else{
                errorMsg(result.msg);
            }
        },
        error:function(result) {
            errorMsg("系统异常");
        }
    });
    return data
}

function setCollegeList() {
    data = getCollegeList()
    htmlstr = ''
    for(i=0;i<data.length;i++){
        tempStr = '<td width="25%" align="center" valign="middle"><a  target="_blank" ' +
            'class="Yuanxi PaddingTop30 college" data-url="/college/guideDetail" title="学院详情" style="border: 0;" data-id="'+data[i]['collegeName']+'">' +
            '<img border="0" src="'+data[i]['collegeImg']+'" /><br />'+data[i]['collegeName']+'</a></td>'
        if (i%4 == 0){
            htmlstr = htmlstr+'<tr>'
            htmlstr = htmlstr+tempStr
        } else if(i%4 == 3){
            htmlstr = htmlstr+tempStr
            htmlstr = htmlstr+'</tr>'
        }else{
            htmlstr = htmlstr+tempStr
        }
    }
    $("#collegeList").html(htmlstr)

}

